package com.mingte.manghe.controller;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xml.internal.security.utils.Base64;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import com.mingte.manghe.entity.LaborInformationEntity;
import com.mingte.manghe.service.LaborInformationService;
import com.mingte.manghe.annotation.LoginRequired;
import com.mingte.manghe.controller.BaseController;
import com.mingte.manghe.common.ResponseResult;
import com.mingte.manghe.exception.UpdateFailException;
import com.mingte.manghe.exception.UserNotExistExecption;
import com.mingte.manghe.utils.JwtUtils;

/**
 * 学生课时操作记录表
 * 
 * @author luxinsheng
 * @email sheng_xin_lu@163.com
 * @date 
 */
@Api(tags = {"学生课时操作记录表"})
@RestController
@RequestMapping("/api/v1/laborinformation")
public class LaborInformationController extends BaseController {

	private final Logger logger = LoggerFactory.getLogger(LaborInformationController.class);

	@Autowired
	private LaborInformationService laborInformationService;
	
	/**
	 * 列表
	 */
	@LoginRequired
	@ApiOperation(value="学生课时操作记录表查询列表数据")
	@RequestMapping("/list")
	public ResponseResult<List<LaborInformationEntity>> list(@RequestParam Map<String, Object> params){

		logger.info("参数========================={}",params);
		//查询列表数据
		List<LaborInformationEntity> laborInformationList = laborInformationService.queryList(params);

		return ResponseResult.success(laborInformationList);
	}
	
	
	/**
	 * 信息
	 */
	@ApiOperation(value="学生课时操作记录表单个信息")
	@RequestMapping("/info/{id}")
	public ResponseResult<LaborInformationEntity> info(
			@ApiParam(name = "id", value = "流水号", required = true)
			@PathVariable("id") Long id){

		logger.info("参数========================={}",id);

		LaborInformationEntity laborInformation = laborInformationService.queryObject(id);
		
		return  ResponseResult.success(laborInformation);
	}
	
	/**
	 * 保存
	 */
	@ApiOperation(value="学生课时操作记录表保存信息")
	@RequestMapping("/save")
	public ResponseResult save(
			@ApiParam(name = "LaborInformation", value = "学生课时操作记录表", required = false)
			@RequestBody LaborInformationEntity laborInformation){
		logger.info("参数========================={}",laborInformation);

		int result = laborInformationService.save(laborInformation);
		
		return result > 0 ? ResponseResult.success() : ResponseResult.fail("保存失败");
	}
	
	/**
	 * 修改
	 */
	@ApiOperation(value="学生课时操作记录表修改信息")
	@RequestMapping("/update")
	public ResponseResult update(
			@ApiParam(name = "LaborInformation", value = "学生课时操作记录表", required = false)
			@RequestBody LaborInformationEntity laborInformation){

		logger.info("参数========================={}",laborInformation);

		int result = laborInformationService.update(laborInformation);

		return result > 0 ? ResponseResult.success() : ResponseResult.fail("修改失败");
	}
	
	/**
	 * 删除
	 */
	@ApiOperation(value="学生课时操作记录表删除信息")
	@GetMapping("/delete")
	public ResponseResult delete(
			@ApiParam(name = "ids", value = "流水号", required = true)
			@RequestBody Long[] ids){

		logger.info("参数========================={}",ids);

		int result = laborInformationService.deleteBatch(ids);

		return result > 0 ? ResponseResult.success() : ResponseResult.fail("删除失败");
	}
	
}
